package org.tio.sitexxx.all;

import org.apache.curator.framework.CuratorFramework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.sitexxx.service.vo.Const;
import org.tio.sitexxx.service.zk.ImServerNodeListener;
import org.tio.utils.zk.ClientDecorator;
import org.tio.utils.zk.Zk;

/**
 * @author tanyaowu 
 * 2016年11月24日 下午1:36:18
 */
public class ZkClientDecorator implements ClientDecorator {
	@SuppressWarnings("unused")
	private static Logger log = LoggerFactory.getLogger(ZkClientDecorator.class);

	public static final ZkClientDecorator me = new ZkClientDecorator();

	/**
	 * 
	 * @author tanyaowu
	 */
	public ZkClientDecorator() {
	}

	/** 
	 * @param zclient
	 * @author tanyaowu
	 * @throws Exception 
	 */
	@Override
	public void decorate(CuratorFramework zclient) throws Exception {
		zclient.getConnectionStateListenable().addListener(ZkConnectionStateListener.me);
		Zk.start();
		Zk.addPathChildrenCacheListener(Const.ZkNode.IM_SERVERS, ImServerNodeListener.me);
	}
}
